package com.jetpackframework.basemd;

import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;

import com.frameworkx.layout.activity_friend;
import com.google.android.material.snackbar.Snackbar;
import com.jetpackframework.R;
import com.jetpackframework.R2;
import com.jetpackframework.base.BaseActivity;
import com.jetpackframework.base.BaseFragment;

/**
 * CollapsingToolbarLayout + FloatingActionButton 实现的仿微信朋友圈首页的滑动效果
 */
public abstract class BaseFriendActivity extends BaseActivity<activity_friend> {
    @Override
    protected void initEventListener() {
        mBinding = getViewBind(R2.layout.activity_friend);
        setContentView(mBinding.getLayoutId());
        mBinding.bindView(getWindow().getDecorView());
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.replace(R.id.frame_content,getContentFragment(),"ContentFragment");
        transaction.commit();
        setTitleBar(mBinding.toolbar);
        mBinding.iv_background.setImageDrawable(getImageBackground());
        mBinding.floatBtn.setBackgroundDrawable(getFloatImageDrawable());
    }

    protected Drawable getFloatImageDrawable() {
        return getResources().getDrawable(R.mipmap.icon_qq);
    }

    protected Drawable getImageBackground() {
        return getResources().getDrawable(R.mipmap.back_img);
    }

    protected abstract void setTitleBar(Toolbar toolbar);

    protected abstract BaseFragment getContentFragment();
}
